<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>hash | 欢迎学习Redis课程</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../redis/shu-ju-cao-zuo/list.html" />
    
    
    <link rel="prev" href="../../redis/shu-ju-cao-zuo/jian-ming-ling.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="1.4.3"
        data-chapter-title="hash"
        data-filepath="redis/shu-ju-cao-zuo/hash.md"
        data-basepath="../.."
        data-revision="Sun Apr 15 2018 01:48:52 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        课程介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="redis.html">
            
                
                    <a href="../../redis.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        Redis
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="redis/an-zhuang.html">
            
                
                    <a href="../../redis/an-zhuang.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        安装
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="redis/pei-zhi.html">
            
                
                    <a href="../../redis/pei-zhi.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="redis/fu-wu-duan-he-ke-hu-duan-ming-ling.html">
            
                
                    <a href="../../redis/fu-wu-duan-he-ke-hu-duan-ming-ling.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        服务端和客户端命令
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="redis/shu-ju-cao-zuo.html">
            
                
                    <a href="../../redis/shu-ju-cao-zuo.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        数据操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="redis/shu-ju-cao-zuo/string.html">
            
                
                    <a href="../../redis/shu-ju-cao-zuo/string.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.1.</b>
                        
                        string
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="redis/shu-ju-cao-zuo/jian-ming-ling.html">
            
                
                    <a href="../../redis/shu-ju-cao-zuo/jian-ming-ling.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.2.</b>
                        
                        键命令
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="1.4.3" data-path="redis/shu-ju-cao-zuo/hash.html">
            
                
                    <a href="../../redis/shu-ju-cao-zuo/hash.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.3.</b>
                        
                        hash
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="redis/shu-ju-cao-zuo/list.html">
            
                
                    <a href="../../redis/shu-ju-cao-zuo/list.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.4.</b>
                        
                        list
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="redis/shu-ju-cao-zuo/set.html">
            
                
                    <a href="../../redis/shu-ju-cao-zuo/set.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.5.</b>
                        
                        set
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="redis/shu-ju-cao-zuo/zset.html">
            
                
                    <a href="../../redis/shu-ju-cao-zuo/zset.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.6.</b>
                        
                        zset
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="redis/yu-python-jiao-hu.html">
            
                
                    <a href="../../redis/yu-python-jiao-hu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        与Python交互
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="redis/yu-python-jiao-hu/strictredis.html">
            
                
                    <a href="../../redis/yu-python-jiao-hu/strictredis.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.1.</b>
                        
                        StrictRedis
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="redis/yu-python-jiao-hu/string.html">
            
                
                    <a href="../../redis/yu-python-jiao-hu/string.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.2.</b>
                        
                        string
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="redis/da-jian-zhu-cong.html">
            
                
                    <a href="../../redis/da-jian-zhu-cong.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        搭建主从
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="redis/da-jian-ji-qun.html">
            
                
                    <a href="../../redis/da-jian-ji-qun.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.</b>
                        
                        搭建集群
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="redis/da-jian-ji-qun/pei-zhi-ji-qi-1.html">
            
                
                    <a href="../../redis/da-jian-ji-qun/pei-zhi-ji-qi-1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.1.</b>
                        
                        配置机器1
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="redis/da-jian-ji-qun/pei-zhi-ji-qi-2.html">
            
                
                    <a href="../../redis/da-jian-ji-qun/pei-zhi-ji-qi-2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.2.</b>
                        
                        配置机器2
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="redis/da-jian-ji-qun/chuang-jian-ji-qun.html">
            
                
                    <a href="../../redis/da-jian-ji-qun/chuang-jian-ji-qun.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.3.</b>
                        
                        创建集群
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="redis/da-jian-ji-qun/yu-python-jiao-hu.html">
            
                
                    <a href="../../redis/da-jian-ji-qun/yu-python-jiao-hu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.4.</b>
                        
                        与Python交互
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >欢迎学习Redis课程</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x5B66;&#x4E60;&#x76EE;&#x6807;">&#x5B66;&#x4E60;&#x76EE;&#x6807; </h1>
<ul>
<li>&#x80FD;&#x591F;&#x5199;&#x51FA;Redis&#x4E2D;hash&#x7C7B;&#x578B;&#x6570;&#x636E;&#x7684;&#x589E;&#x5220;&#x6539;&#x67E5;&#x76F8;&#x5173;&#x547D;&#x4EE4;</li>
</ul>
<h1 id="hash&#x7C7B;&#x578B;">hash&#x7C7B;&#x578B; </h1>
<ul>
<li>hash&#x2F64;&#x4E8E;&#x5B58;&#x50A8;&#x5BF9;&#x8C61;&#xFF0C;&#x5BF9;&#x8C61;&#x7684;&#x7ED3;&#x6784;&#x4E3A;&#x5C5E;&#x6027;&#x3001;&#x503C;</li>
<li>&#x503C;&#x7684;&#x7C7B;&#x578B;&#x4E3A;string</li>
</ul>
<h2 id="&#x589E;&#x52A0;&#x3001;&#x4FEE;&#x6539;">&#x589E;&#x52A0;&#x3001;&#x4FEE;&#x6539; </h2>
<ul>
<li><p>&#x8BBE;&#x7F6E;&#x5355;&#x4E2A;&#x5C5E;&#x6027;</p>
<blockquote>
<p>hset key field value</p>
</blockquote>
</li>
<li><p>&#x4F8B;1&#xFF1A;&#x8BBE;&#x7F6E;&#x952E; user&#x7684;&#x5C5E;&#x6027;name&#x4E3A;itheima</p>
<blockquote>
<p>hset user name itheima</p>
</blockquote>
<p><img src="../../assets/p1_26.png" alt="" title="&#x8BBE;&#x7F6E;&#x952E;"></p>
</li>
</ul>
<p>MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.</p>
<p>Redis&#x88AB;&#x914D;&#x7F6E;&#x4E3A;&#x4FDD;&#x5B58;&#x6570;&#x636E;&#x5E93;&#x5FEB;&#x7167;&#xFF0C;&#x4F46;&#x5B83;&#x76EE;&#x524D;&#x4E0D;&#x80FD;&#x6301;&#x4E45;&#x5316;&#x5230;&#x786C;&#x76D8;&#x3002;&#x7528;&#x6765;&#x4FEE;&#x6539;&#x96C6;&#x5408;&#x6570;&#x636E;&#x7684;&#x547D;&#x4EE4;&#x4E0D;&#x80FD;&#x7528;</p>
<p>&#x539F;&#x56E0;&#xFF1A;</p>
<ul>
<li><p>&#x5F3A;&#x5236;&#x5173;&#x95ED;Redis&#x5FEB;&#x7167;&#x5BFC;&#x81F4;&#x4E0D;&#x80FD;&#x6301;&#x4E45;&#x5316;&#x3002; &#x89E3;&#x51B3;&#x65B9;&#x6848;&#xFF1A;</p>
</li>
<li><p>&#x8FD0;&#x884C;config set stop-writes-on-bgsave-error no&#x3000;&#x547D;&#x4EE4;&#x540E;&#xFF0C;&#x5173;&#x95ED;&#x914D;&#x7F6E;&#x9879;stop-writes-on-bgsave-error&#x89E3;&#x51B3;&#x8BE5;&#x95EE;&#x9898;&#x3002;</p>
</li>
<li><p>&#x8BBE;&#x7F6E;&#x591A;&#x4E2A;&#x5C5E;&#x6027;</p>
<blockquote>
<p>hmset key field1 value1 field2 value2 ...</p>
</blockquote>
</li>
<li><p>&#x4F8B;2&#xFF1A;&#x8BBE;&#x7F6E;&#x952E;u2&#x7684;&#x5C5E;&#x6027;name&#x4E3A;itcast&#x3001;&#x5C5E;&#x6027;age&#x4E3A;11</p>
<blockquote>
<p>hmset u2 name itcast age 11</p>
</blockquote>
<p><img src="../../assets/p1_28.png" alt="" title="&#x8BBE;&#x7F6E;&#x591A;&#x4E2A;&#x5C5E;&#x6027;"></p>
</li>
</ul>
<h2 id="&#x83B7;&#x53D6;">&#x83B7;&#x53D6; </h2>
<ul>
<li><p>&#x83B7;&#x53D6;&#x6307;&#x5B9A;&#x952E;&#x6240;&#x6709;&#x7684;&#x5C5E;&#x6027;</p>
<blockquote>
<p>hkeys key</p>
</blockquote>
</li>
<li><p>&#x4F8B;3&#xFF1A;&#x83B7;&#x53D6;&#x952E;u2&#x7684;&#x6240;&#x6709;&#x5C5E;&#x6027;</p>
<blockquote>
<p>hkeys u2</p>
</blockquote>
<p><img src="../../assets/p1_29.png" alt="" title="&#x83B7;&#x53D6;&#x952E;&#x5C5E;&#x6027;"></p>
</li>
<li><p>&#x83B7;&#x53D6;&#x2F00;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x503C;</p>
<blockquote>
<p>hget key field</p>
</blockquote>
</li>
<li><p>&#x4F8B;4&#xFF1A;&#x83B7;&#x53D6;&#x952E;u2&#x5C5E;&#x6027;&apos;name&apos;&#x7684;&#x503C;</p>
<blockquote>
<p>hget u2 &apos;name&apos;</p>
</blockquote>
<p><img src="../../assets/p1_30.png" alt="" title="&#x83B7;&#x53D6;&#x952E;&#x5C5E;&#x6027;&#x503C;"></p>
</li>
<li><p>&#x83B7;&#x53D6;&#x591A;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x503C;</p>
<blockquote>
<p>hmget key field1 field2 ...</p>
</blockquote>
</li>
<li><p>&#x4F8B;5&#xFF1A;&#x83B7;&#x53D6;&#x952E;u2&#x5C5E;&#x6027;&apos;name&apos;&#x3001;&apos;age&#x7684;&#x503C;</p>
<blockquote>
<p>hmget u2 name age</p>
</blockquote>
<p><img src="../../assets/p1_31.png" alt="" title="&#x83B7;&#x53D6;&#x952E;&#x5C5E;&#x6027;&#x503C;"></p>
</li>
<li><p>&#x83B7;&#x53D6;&#x6240;&#x6709;&#x5C5E;&#x6027;&#x7684;&#x503C;</p>
<blockquote>
<p>hvals key</p>
</blockquote>
</li>
<li><p>&#x4F8B;6&#xFF1A;&#x83B7;&#x53D6;&#x952E;&apos;u2&apos;&#x6240;&#x6709;&#x5C5E;&#x6027;&#x7684;&#x503C;</p>
<blockquote>
<p>hvals u2</p>
</blockquote>
<p><img src="../../assets/p1_32.png" alt="" title="&#x83B7;&#x53D6;&#x952E;&#x5C5E;&#x6027;&#x503C;"></p>
</li>
</ul>
<h2 id="&#x5220;&#x9664;">&#x5220;&#x9664; </h2>
<ul>
<li>&#x5220;&#x9664;&#x6574;&#x4E2A;hash&#x952E;&#x53CA;&#x503C;&#xFF0C;&#x4F7F;&#x2F64;del&#x547D;&#x4EE4;</li>
<li><p>&#x5220;&#x9664;&#x5C5E;&#x6027;&#xFF0C;&#x5C5E;&#x6027;&#x5BF9;&#x5E94;&#x7684;&#x503C;&#x4F1A;&#x88AB;&#x2F00;&#x8D77;&#x5220;&#x9664;</p>
<blockquote>
<p>hdel key field1 field2 ...</p>
</blockquote>
</li>
<li><p>&#x4F8B;7&#xFF1A;&#x5220;&#x9664;&#x952E;&apos;u2&apos;&#x7684;&#x5C5E;&#x6027;&apos;age&apos;</p>
<blockquote>
<p>hdel u2 age</p>
</blockquote>
<p><img src="../../assets/p1_33.png" alt="" title="&#x83B7;&#x53D6;&#x952E;&#x5C5E;&#x6027;&#x503C;"></p>
</li>
</ul>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../redis/shu-ju-cao-zuo/jian-ming-ling.html" class="navigation navigation-prev " aria-label="Previous page: 键命令"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../redis/shu-ju-cao-zuo/list.html" class="navigation navigation-next " aria-label="Next page: list"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
